package com.cryptoneedle.garden.repository.garden.ods;


import com.bubbles.engine.data.core.repository.BaseRepository;
import com.cryptoneedle.garden.entity.garden.ods.OdsColumnTranslate;
import com.cryptoneedle.garden.key.OdsColumnTranslateKey;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>description: Ods-SourceColumn </p>
 *
 * @author CryptoNeedle
 * @date 2025-09-25
 */
@Repository
public interface OdsColumnTranslateRepository extends BaseRepository<OdsColumnTranslate, OdsColumnTranslateKey> {

    @Query("FROM OdsColumnTranslate ORDER BY catalogName, databaseName, tableName, columnName, translateType, sequence")
    List<OdsColumnTranslate> odsColumnTranslates();

    @Query("""
             FROM OdsColumnTranslate
            WHERE catalogName = :catalogName
            ORDER BY catalogName, databaseName, tableName, columnName, translateType, sequence
            """)
    List<OdsColumnTranslate> odsColumnTranslates(String catalogName);

    @Query("""
             FROM OdsColumnTranslate
            WHERE catalogName = :catalogName
              AND databaseName = :databaseName
            ORDER BY catalogName, databaseName, tableName, columnName, translateType, sequence
            """)
    List<OdsColumnTranslate> odsColumnTranslates(String catalogName, String databaseName);

    @Query("""
             FROM OdsColumnTranslate
            WHERE catalogName = :catalogName
              AND databaseName = :databaseName
              AND tableName = :tableName
            ORDER BY catalogName, databaseName, tableName, columnName, translateType, sequence
            """)
    List<OdsColumnTranslate> odsColumnTranslates(String catalogName, String databaseName, String tableName);

    @Query("""
             FROM OdsColumnTranslate
            WHERE catalogName = :catalogName
              AND databaseName = :databaseName
              AND tableName = :tableName
              AND columnName = :columnName
            ORDER BY catalogName, databaseName, tableName, columnName, translateType, sequence
            """)
    List<OdsColumnTranslate> odsColumnTranslates(String catalogName, String databaseName, String tableName, String columnName);
}